<template>
  <div class="inputComment">
    <div>
      <div class="cshadow" @click="hideInput"></div>
      <div class="input_model">
     <textarea placeholder="请输入你的评论" v-model="comment" autofocus>

     </textarea>
        <div class="btn" :class="{'can_send':can_send}" @click="sendComment">发送</div>
      </div>
    </div>
  </div>
</template>

<script>
  import {mapMutations,mapActions} from 'vuex'

  export default {
    name: 'InputComment',
    watch: {
      comment() {
        if (this.comment.length > 0) {
          this.can_send = true
        } else {
          this.can_send = false
        }
      }
    },
    data() {
      return {
        comment: '',
        can_send: false
      }
    },
    methods: {
      ...mapMutations(['changeIsInput']),
      ...mapActions(['loadComment']),
      hideInput() {
        this.changeIsInput(false)
      },
      /*发送频率*/
      sendComment(){
        if(!this.can_send){
          return
        }
        /*发送请求，成功后请求最新的评论*/


      }
    }
  }
</script>

<style scoped>
  .inputComment {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
  }

  .inputComment .can_send {
    color: #059692;
  }

  .inputComment > div {
    position: relative;
    width: 100%;
    height: 100%;
  }

  .cshadow {
    background-color: rgba(0, 0, 0, 0.51);
    width: 100%;
    height: 100%;
  }

  .input_model {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 26px 18px 26px;
    background-color: white;
  }

  textarea {
    width: 570px;
    border-radius: 30px;
    background-color: #f2f2f2;
    padding: 18px 16px  18px 20px;
    border: none;
    box-sizing: border-box;
    outline: none;
    font-size: 28px;
    color: #333;
  }

  .btn {
    float: right;
    font-size: 28px;
    color: #999;
    font-weight: bold;
    line-height: 96px;
    margin-right: 13px;
  }
</style>
